home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1997 #3
/
Amiga Plus CD - 1997 - No. 03.iso
/
pd
/
demo-versionen
/
maxoncpp4-demo
/
demo
/
supercode
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-31
|
5KB
|
218 lines
//-------------------------------------
//
// SuperCode (c) 1996 by T.Kühn
//
// Programmiersprache: ANSI-C
// Projektstart: 12.7.94
//
// Modul: Main
//
//-------------------------------------
//-------------------------------------
#include <pragma/exec_lib.h>
#include <pragma/dos_lib.h>
#include <pragma/intuition_lib.h>
#include <exec/memory.h>
#include <stdarg.h>
#include <wbstartup.h>
#include <Struct.h>
//-------------------------------------
BOOL exit_flag;
ULONG Memory_Strt,Memory_Ende;
BOOL
init_lib=FALSE,
init_loc=FALSE,
init_prefs=FALSE,
init_class=FALSE,
init_msg=FALSE,
init_super=FALSE,
init_menu=FALSE,
init_scrn=FALSE,
init_code=FALSE,
init_score=FALSE;
//-------------------------------------
void Exit_All()
{
exit_flag=TRUE;
if (init_score) score_free();
if (init_super) supercode_free();
if (init_prefs) prefs_free();
if (init_menu) Menu_Free();
if (init_scrn) Screen_Close(&Scrn);
if (init_class) Class_Free();
if (init_msg ) MsgPort_Free();
if (init_code) code_free();
if (init_loc) loc_free();
if (init_lib ) Lib_Free();
Memory_Ende=AvailMem(MEMF_PUBLIC);
if ( (Memory_Strt-Memory_Ende)!=0 )
{
Printf("Warning !!!\nProgramm lost %ld bytes of Memory !!!\n",Memory_Strt-Memory_Ende);
Delay(50);
}
exit(0);
}
//-------------------------------------
//-------------------------------------
ULONG display_errorA(ULONG error,ULONG ask,ULONG *args)
{
#define MAX_TXT (80)
ULONG back =ASK_CONT;
if (error)
{
struct EasyStruct easy=
{
sizeof (struct EasyStruct),
0,
CatStr(TXT_ERR_TITLE),
(error<TXT_END) ? CatStr(error) : (UBYTE*) error,
0,
};
UBYTE txt[MAX_TXT+2];
ULONG max=0,ask_res[ASK_END];
txt[0]=0;
if (ask & ASK_YES) {ask_res[++max]=ASK_YES; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_YES),MAX_TXT); }
if (ask & ASK_OK) {ask_res[++max]=ASK_OK; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_OK),MAX_TXT); }
if (ask & ASK_AGAIN) {ask_res[++max]=ASK_AGAIN; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_AGAIN),MAX_TXT); }
if (ask & ASK_CONT) {ask_res[++max]=ASK_CONT; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_CONT),MAX_TXT); }
if (ask & ASK_SAVE) {ask_res[++max]=ASK_SAVE; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_SAVE),MAX_TXT); }
if (ask & ASK_SELECT) {ask_res[++max]=ASK_SELECT;if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_SELECT),MAX_TXT);}
if (ask & ASK_ABORT) {ask_res[++max]=ASK_ABORT; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_ABORT),MAX_TXT); }
if (ask & ASK_EXIT) {ask_res[++max]=ASK_EXIT; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_EXIT),MAX_TXT); }
if (ask & ASK_NO) {ask_res[++max]=ASK_NO; if (max>1) StrAdd(txt,"|",MAX_TXT); StrAdd(txt,CatStr(TXT_ERR_NO),MAX_TXT); }
easy.es_GadgetFormat=txt;
if (max>0)
{
ask_res[0]=ask_res[max];
if (IntuitionBase) back=ask_res[EasyRequestArgs(0,&easy,0,args)];
else Exit_All();
if (back==ASK_EXIT) Exit_All();
if (back==ASK_CONT)
{
easy.es_TextFormat=CatStr(TXT_CONT);
easy.es_GadgetFormat=CatStr(TXT_CONTANS);
if (0==EasyRequestArgs(0,&easy,0,0)) Exit_All();
}
}
}
return back;
}
//-------------------------------------
ULONG display_error(ULONG error,ULONG ask ...)
{
ULONG back;
va_list args;
va_start(args,ask);
back=display_errorA(error,ask,(ULONG*)args);
va_end(args);
return back;
}
//-------------------------------------
//-------------------------------------
void Quit()
{
LONG res;
if (!player1.finish && player1.started)
{
res=display_error((ULONG)CatStr(TXT_MAINQUITSAVE),ASK_YES|ASK_ABORT|ASK_SAVE);
}
else
{
res=display_error((ULONG)CatStr(TXT_MAINQUIT),ASK_YES|ASK_ABORT);
}
switch (res)
{
case ASK_SAVE:
supercode_savegame();
case ASK_YES:
Exit_All();
break;
}
}
//-------------------------------------
void main()
{
exit_flag=TRUE;
Memory_Strt=AvailMem(MEMF_PUBLIC);
init_lib=TRUE;
Lib_Init();
init_loc=TRUE;
loc_init(0);
init_prefs=TRUE;
prefs_init();
init_code=TRUE;
code_init();
init_class=TRUE;
Class_Init();
init_msg=TRUE;
MsgPort_Init();
init_score=TRUE;
score_init();
init_menu=TRUE; // !!! Das ist nicht PASCAL oder MODULA '=' anstatt ':=' !!!
Menu_Init();
init_scrn=TRUE;
Screen_Init(&Scrn);
Screen_Open(&Scrn);
init_super=TRUE;
supercode_init();
supercode_open();
exit_flag=FALSE;
supercode_about();
// supercode_newplayer();
while(TRUE)
{
while(TRUE)
{
supercode_domsg();
score_domsg();
prefs_domsg();
wait_mask(supercode_getbit() | score_getbit() | prefs_getbit());
}
Quit();
}
}
//-------------------------------------